package com.example.chasshelper;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.chasshelper.dao.ClassroomDao;
import com.example.chasshelper.dao.CourseDao;
import com.example.chasshelper.dao.MessageDao;
import com.example.chasshelper.dao.RegistrationDao;
import com.example.chasshelper.dao.SolutionDao;
import com.example.chasshelper.dao.StudentDao;
import com.example.chasshelper.dao.TeacherDao;
import com.example.chasshelper.dao.TestDao;
import com.example.chasshelper.model.Student;
import com.example.chasshelper.model.Teacher;
import com.example.chasshelper.utils.DaoUtils;


/*
* 从SubjectTeaFragment跳转而来
* */
public class CreateSubjectActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = CreateSubjectActivity.class.getSimpleName();
    private final Activity mContext = CreateSubjectActivity.this;
    //控件
    private Button btn_back;
    private Button btn_create;
    private EditText et_name;

    //dao
    private TeacherDao teacherDao= DaoUtils.getTeacherDao();
    private StudentDao studentDao=DaoUtils.getStudentDao();
    private CourseDao courseDao=DaoUtils.getCourseDao();
    private ClassroomDao classroomDao=DaoUtils.getClassroomDao();
    private RegistrationDao registrationDao=DaoUtils.getRegistrationDao();
    private SolutionDao solutionDao = DaoUtils.getSolutionDao();
    private MessageDao messageDao = DaoUtils.getMessageDao();
    private TestDao testDao = DaoUtils.getTestDao();
    //数据
    private Teacher teacher;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_creat_subject);
        //初始化界面
        initUI();
        //初始化数据
        initData();
    }
    private void initUI() {
        //绑定控件
        btn_back = findViewById(R.id.btn_back);
        btn_create = findViewById(R.id.btn_create);
        et_name = findViewById(R.id.et_name);
        //点击事件
        btn_back.setOnClickListener(this);
        btn_create.setOnClickListener(this);
    }

    private void initData() {
        teacher = (Teacher) getIntent().getSerializableExtra("teacher");
        //dao实例化
        //adapter实例化：无
    }


    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        String courseName = et_name.getText().toString();
        switch (view.getId()) {
            case R.id.btn_back://返回
                finish();
                break;
            case R.id.btn_create://创建课程:
                courseDao.insert(courseName,teacher);
                finish();
                break;
        }
    }

}